<template>
	<view >
		<home-barTittle :title="title" :showBack="true"></home-barTittle>
		<view class="mphtml pd16_15 mb16 cl-main">
			<mp-html :content="info.activityInfo"/>
		</view>
		<!-- <view class="activity-info-bottom pd20_15">
			<view class="ft18 cl-main ftw600">活动主题：{{info.activityName}}</view>
			<view class="ft18 cl-main ftw600">活动费用：{{info.activityCost}}</view>
			<view class="ft18 cl-main ftw600">活动时间：{{info.activityTime}}</view>
			<view class="ft18 cl-main ftw600">活动地址：{{info.activityAddress}}</view>
			<button class="button-signin" style="margin-top: 35rpx; font-size: 40upx; color: #000000; height: 80rpx; line-height: 80rpx;"
				 withCredentials="true">点击报名</button>
		</view> -->
		
		
		<dialog-login v-if="showLogin" @loginYes="loginYes" @closed="showLogin = false"></dialog-login>
		
	</view>
</template>

<script>

import infoVue from './info.vue';
// import mapTencent from '@/components/map/map-tencent.vue';
// import mpHtml from 'mp-html/dist/components/mp-html/mp-html'
// import zaudio from 'uniapp-zaudio/zaudio'

export default {
	
	data(){
		return {
			title:"精彩回顾",
			processedRichText:'',
			
			isLogin:false,
			showLogin:false,
			showVideo:false,
			autoplay:false,
			playbtn:true,
			selectIndex:0,
			tabs:['目录','详情'],
			nextStep:'',
			datasa:[],
			dataconfig:[],
			id:'',
			mid:0,
			info:{},
			userPaidStatus:'',
			dda:'',
			price:'',
			banners:[],
			isplaytext:'已经购买',
			audioAction: {
				method: 'pause'
			}
		}
	},
	computed: {
		// processedRichText() {
		// 	// 处理图片自适应
		// 	return this.processedRichText.replace(/<img/gi, '<img style="max-width:100%;height:auto;"');
		// }
	},
	onLoad(option){
		// this.dda=uni.createVideoContext('myVideo')
		if(option.reviewId){
			this.id=option.reviewId
		}
	},
	onShow() {
		
		if(uni.getStorageSync("userinfo").token){
			this.isLogin = true
			this.showLogin = false
		}
		
		this.getinfo(this.id);
		// 判断当前用户是否已经购买当前景区视频权限
		// this.checkPaid(this.id);
		
		// this.banners=uni.getStorageSync("config").banner
	},
	onHide() {
		// this.dda.pause()
	},
	onShareAppMessage(e){
		
	},
	onShareTimeline(e){
		
	},
	methods:{
			
			getinfo(id) {
				console.log("getInfo")
				uni.showLoading({
				    title: '加载中'
				});
				if(uni.getStorageSync("userinfo").token){
					data.token=uni.getStorageSync("userinfo").token
					this.isLogin = true
				}
				uni.request({
					url: this.configs.webUrl+'/miniapp/review/'+id ,
					// data: data,
					success: data => {
							uni.hideLoading();
							this.info={};
							this.info=data.data.data
							console.log('this.info')
							console.log(this.info)
							this.processedRichText = this.info.activityInfo
							console.log("richText")
							console.log(this.processedRichText)
							
							uni.setNavigationBarTitle({
							    title: this.info.activityName
							});
					},
					fail: (data, code) => {
						uni.hideLoading();
					}
				});
			},
			// 判断当前用户是否已经购买了当前景区的视频权限（购买任一视频权限，均开放当前景区内的所有视频权限）
			checkPaid(scenicId){
				var userinfo = uni.getStorageSync("userinfo");
				uni.request({
					url: this.configs.webUrl+'/api/scenicArea/checkPaid',
					data: {
						userId: userinfo.id,
						scenicAreaId: scenicId
					},
					method:'POST',
					
					success: data => {
						console.log("checkPaid");
						this.userPaidStatus = data.data.data;
						console.log(this.userPaidStatus);
						
						// this.checkShowVideo();
					},
					fail: (data, code) => {
					}
				});
			},
			checkShowVideo(){
				// 1.景区免费
				// 2.景区收费&景点免费
				// 3.景区收费&已付费
				this.showVideo = true;
			},
			// getList() { 
			// 	let data = {
			// 		//column: 'id,post_id,title,author_name,cover,published_at' //需要的字段名
			// 	};
			// 	var limit=10;
			// 	data.limit=limit
			// 	data.ishot=2
			// 	uni.request({
			// 		url: this.configs.webUrl+'/api/video/list',
			// 		data: data,
			// 		success: data => {
						
			// 			uni.setStorage({//缓存配置信息
			// 				key: 'config',  
			// 				data: data.data.config
			// 			})
			// 			if (data.data.total>0) {
			// 				this.dataconfig=data.data.config
			// 				this.datasa=data.data.rows
			// 			}
			// 		},
			// 		fail: (data, code) => {
			// 		}
			// 	});
			// },
			contactAct(){
				if(this.isLogin == false){
					this.showLogin = true;
					this.nextStep = 'contact';
				}else{
					uni.navigateTo({
						url:'/pages/client/vipcard/adviser'
					})
				}
			},
			vipcard(){
				uni.navigateTo({
					url:'/pages/client/vipcard/index'
				})
			},
			detail(id,mid){
				uni.navigateTo({
					url:'/sub_pages/scenicArea/detail?id='+id+'&mid='+mid
				})
				
				// console.log("收费："+this.info.chargeStatus)
				// if(this.info.chargeStatus & !this.userPaidStatus){
				// 	uni.navigateTo({
				// 		url:'/sub_pages/scenicArea/buy?id='+id+'&mid='+mid
				// 	})
				// }else{
				// 	uni.navigateTo({
				// 		url:'/sub_pages/scenicArea/detail?id='+id+'&mid='+mid
				// 	})
				// }
				
			},
			buyAct(){
				if(this.price*1==0){
					uni.showToast({ title: '免费视频不需要购买',icon:"none" });
					return false; 
				}
				if(this.isLogin == false){
					this.showLogin = true;
					this.nextStep = 'buy';
				}else{
					uni.setStorage({//缓存配置信息
						key: 'buydata',  
						data: this.info
					})
					uni.navigateTo({
						url:'/sub_pages/scenicArea/buy?id='+this.id
					})
				}
			},
			loginYes(){
				if(this.nextStep == 'buy'){
					uni.navigateTo({
						url:'/sub_pages/scenicArea/buy'
					})
				}else{
					uni.navigateTo({
						url:'/pages/client/vipcard/adviser'
					})
				}
			},
			changeIndex(index){
				this.selectIndex = index;
			}
		}
	}
</script>

<style>

	/* 富文本自动换行 */
	.mphtml{
		white-space: pre-wrap; /* CSS3 */
		word-wrap: break-word; /* Internet Explorer 5.5+ */
		padding-bottom: 200px;
	}
	/* 底部悬浮框 */
	.activity-info-bottom{
		width: 100%;
		background: #FFFFFF;
		border-radius: 40rpx 40rpx 0rpx 0rpx;
		position: fixed;
		bottom: 0;
		margin-top: 20rpx;
	}
	/* 报名按钮 */
	.button-signin{
		color: #FFFFFF;
		font-size: 34rpx;
		width: 470rpx;
		height: 100rpx;
		background: linear-gradient(-90deg, rgba(75, 196, 93, 1), rgba(188, 226, 158, 1));
		box-shadow: 0rpx 0rpx 13rpx 0rpx rgba(164, 217, 228, 0.2);
		border-radius: 50rpx;
		line-height: 100rpx;
		text-align: center;
		margin-left: auto;
		margin-right: auto;
		margin-top: 100rpx;
	}
</style>